<?php
class GoogleGeolocation{
	
	    public $OutputType = "json";  //either json, xml or array
 
		public $Errors	= array();
 
		private $APIUrl = "http://maps.googleapis.com/maps/api/geocode";
		private $APICallType = "";
		//private $APIKey = "AIzaSyBdz1QrJm13DBxGuvhi-o19uC4HVjrN1Zg";
		public $sensor = "true";
		
		public $address;
		
		public $UrlToCall;
		
		public function setAddress($address)
		{
			$this->address = $address;
		}
		
		public function search()
		{
				
			return $this->APICall();
		}
		
		public function APICall()
		{
			
			$UrlToCall = $this->APIUrl."/".$this->OutputType."?address=".urlencode($this->address)."&sensor=".$this->sensor;
			
			$result = json_decode(file_get_contents($UrlToCall), true);
			
			return $result;
		}
}